define(['app'], function(app) {
	'use strict';

	// 实例化方法
	var factory = function(Http) {
		function get_data_get_list(result){
			if(false){
				result = '{"success": true,"msg": "","result": {"findgoods": ['+
            '{"id": "001","title": "求购螺丝刀","create_time": "2017/01/01 09:00:00","region": "江苏","goods_count": 100,"offer_count": 50,"store_name": "世达","last_day": 5,"cat_type": "手动工具-扳手-手动扳手"},'+
            '{"id": "002","title": "求购螺丝刀","create_time": "2017/01/01 09:00:00","region": "上海","goods_count": 1100,"offer_count": 70,"store_name": "微星","last_day": 6,"cat_type": "手动工具-扳手1-手动扳手2"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
            return JSON.parse(result);
			}else
			return result;
		}
		
		// 返回信息
		return {
			//获取求购信息列表
			get_list : function(key, nPage, order, callback,calldone) {
				Http.post({
						method : 'info.findgoods.getlist',
						key : key,
						order : order,
						nPage:nPage,
						pagelimit:10
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_get_list(result).result);
					},
					function(e) {
						//请求异常

					},
					function() {
						//请求完成，一般不做什么事情
						if(calldone)
						calldone();
					}
				);
			}

			
		};
	}

	factory.$inject = [ 'Http' ];
	return app.registerService("Searchorder", factory);
});